package com.qiangesoft.mybatisflex.config;

import com.mybatisflex.core.tenant.TenantFactory;
import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.RequestContextHolder;

/**
 * 自定义租户工厂
 */
public class MyTenantFactory implements TenantFactory {

    @Override
    public Object[] getTenantIds() {
        RequestAttributes attributes = RequestContextHolder.getRequestAttributes();
        Object tenantId = attributes.getAttribute("tenantId", RequestAttributes.SCOPE_REQUEST);
        return new Object[]{tenantId};
    }

}